<?php
/**
 * Name
 * 2018/11/5
 * ╔═════╗                 ╔═╗ ╔═╗
 * ║ ╔═══╝                 ║ ║ ║ ║
 * ║ ╚═══╦══╦══╦═════╦═════╣ ╚═╝ ║
 * ╚═══╗ ║  ║  ║  ║  ║  ║  ╠═╗ ╔═╝
 * ╔═══╝ ║  ║  ║  ║  ║  ║  ║ ║ ║
 * ╚═════╩═════╩══╩══╩══╩══╝ ╚═╝
 */

namespace App\Models;


use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;

class ExportLog extends Model
{
    protected $table = 'export_log';

    const StatusWait = 1;//执行中
    const StatusSuccess = 2;//执行完成
    const StatusFail = 3;//执行完成

    protected $fillable = ['filename','status'];

    protected $appends = ['status_txt'];


    static public function statusTemplate(){
        return [
            static::StatusWait              => '正在导出。。。',
            static::StatusSuccess           => '导出完成',
            static::StatusFail              => '导出失败',
        ];
    }

    public function getCompletedAtAttribute($value){
        return $value ? date('Y-m-d H:i:s',$value) : '';
    }

    public function getStatusTxtAttribute(){

        return static::statusTemplate()[$this->status];
    }
}